<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<title>view/workArea/tools/borrowTools</title>
		<!-- css代码 start -->
		<link href="../../../css/mui.min.css" rel="stylesheet" />
		<link href="../../../css/global.css" rel="stylesheet" />
		<link href="../../../css/style.css" rel="stylesheet" />
		<link href="../../../css/checkbox.css" rel="stylesheet" />
		<link href="../../../css/mui.picker.css" rel="stylesheet" />
		<link href="../../../css/mui.poppicker.css" rel="stylesheet" />
		<link href="../../../css/task.css" rel="stylesheet" />
		<style>
			.d_int_tp{
				border: 0 !important;
				margin-top: 6px !important;
			}
			.select-tzstate{
				width: 100%;
				border: 0;
				color: #a9a9a9;
				font-size: 16px;
				text-align: left;
				padding: 15px;
			}
			.mui-bar-nav{
				box-shadow: 0 1px 6px #ea1e1a;
			}
			.mui-checkbox input[type=checkbox], .mui-radio input[type=radio]{
				top: 8px;
				right: -10px;
			}
		</style>
		<!-- css代码 end -->
	</head>
	<body>

		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 id="title" class="mui-title">工具申请</h1>
		</header>
		<div class="mui-content">
			<div class="details_con select_con" id="search">
				<div class="clum">
					<input type="text" class="d_int_tp" id="toolNo" placeholder="请输入工具物料号" />
				</div>
				<div class="clum">
					<input type="text" class="d_int_tp" id="toolNname" placeholder="请输入工具名称" />
				</div>
				<!--<div class="clum">
					<span class="txt" style="width: 100%;">
						<input type="hidden" id="status" value=""/>
						<button id="statusSel" class="mui-btn mui-btn-block mui-btn-select select-tzstate" type="button">请选择工具状态</button>
					</span>
				</div>-->
				<div class="btm autoHeight">
					<p class="selectBtn" id="searchBtn" onclick="selectList()">查 询</p>
				</div>
			</div>
			
			<div class="details_con" style="margin: 30px 0 0 0;">
				<div class="item_box" id="itemBox">
					<!-- <div class="item">
						<div class="bar">
							<span class="number">1170001<img src="../../../images/icon_80.png" /></span>
							<div class="checkbox">
								<div class="mui-input-row mui-checkbox"> 
									<input name="checkbox1" value="运动" type="checkbox" class="rdss"/> 
									<label></label> 
								</div> 
							</div>
						</div>
						<div class="text">
							<span class="l">工具名称：</span> 
							工具1
						</div>
						<div class="type">
							<p>工具属性：<span>固定资产</span><img src="../../../images/icon_87.png"/></p>
							<p>工具状态：<span>完好闲置</span><img src="../../../images/icon_88.png"/></p>
							<p>参数：<span>121212</span><img src="../../../images/icon_94.png"/></p>
						</div>
					</div> -->
				</div>
				<div class="btn_box">
					<span class="fl red one" id="submitBtn">批量申请</span>
				</div>
			</div>
		</div>



		<!-- js代码 start -->

		<!-- 基础js start -->
		<script src="../../../js/mui.min.js"></script>
		<script src="../../../js/utils/h.js"></script>
		<script src="../../../js/constant.js"></script>
		<script src="../../../js/common.js"></script>
		<script src="../../../js/utils/base64.js"></script>
		<script src="../../../js/utils/md5.js"></script>
		<script src="../../../js/utils/sortMap.js"></script>
		<script src="../../../js/utils/http.js"></script>
		<script src="../../../js/app.js"></script>
		<script src="../../../js/mui.picker.js"></script>
		<script src="../../../js/mui.poppicker.js"></script>
		<!-- 基础js end -->

		<script>
			(function($, doc) {
				$.init();
			
				$.plusReady(function() {
					// 查询可借用工具列表（完好闲置）
					selectList();
					
					// 批量申请
					h("#submitBtn").tap(function() {
						var tools = new Array();
						var toolIds = new Array();
						var ele = document.getElementsByName("checkbox1");
						for (var i = 0; i < ele.length; i++) {
							if(ele[i].checked){
								// 选中的工具信息
								var info = {};
								info["tool_id"] = ele[i].value;
								info["tool_no"] = ele[i].getAttribute("toolNo");
								info["Tool_name"] = ele[i].getAttribute("toolName");
								// 申请所需参数
								tools.push(info);
								toolIds.push(ele[i].getAttribute("toolNo"));
							}
						}
						if (tools.length === 0) {
							app.toast("请选择工具");
						} else {
							// 申请页
							app.jumpTo("applyTools.html", "view/workArea/tools/applyTools", {
								"tools" : JSON.stringify(tools),
								"toolIds" : toolIds
							});
						}
					})
				});
			}(mui, document));
			
			// 查询可借用工具列表(使用post请求)
			function selectList() {
				var toolNo = h("#toolNo").val();
				var toolNname = h("#toolNname").val();
				var enginnerId = app.getUser().enginnerId;

				ajaxPost(BASE_URL + "cc/tool/getBorrowTool", {
					"enginnerId": enginnerId,
					"status": "1",
					"toolNo": toolNo,
					"toolNname": toolNname
				}, function(data) {
					if (data.code === 200) {
						var str = '';
						var dataObj = JSON.parse(data.data);
						var list = dataObj.record;
						// 无数据
						if (list.length == 0) {
							h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
							return false;
						}
						// 显示列表
						for (var i = 0; i < list.length; i++) {
							var info = list[i];
							str += '<div class="item">';
							str += '<div class="bar">';
							str += '<span class="number">'+ info.tool_no +'<img src="../../../images/icon_204.png" /></span>';
							str += '<div class="checkbox">';
							str += '<div class="mui-input-row mui-checkbox"> ';
							str += '<input name="checkbox1" value="'+ info.tool_id +'" toolNo="'+ info.tool_no +'" toolName="'+ info.Tool_name +'" type="checkbox" class="rdss"/> ';
							str += '<label></label> ';
							str += '</div> ';
							str += '</div>';
							str += '</div>';
							str += '<div class="text">';
							str += '<span class="l">工具名称：</span> ' + emptyStr(info.Tool_name);
							str += '</div>';
							str += '<div class="type">';
							str += '<p>工具属性：<span>'+ emptyStr(info.tools_type) +'</span><img src="../../../images/icon_221.png"/></p>';
							str += '<p>工具状态：<span>'+ emptyStr(info.tool_status) +'</span><img src="../../../images/icon_205.png"/></p>';
							str += '<p>参数：<span>'+ emptyStr(info.Parameter) +'</span><img src="../../../images/icon_222.png"/></p>';
							str += '</div>';
							str += '</div>';
						}
						h('#itemBox').html(str);
					} else {
						h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
						app.toast(data.msg)
					}
				}, function(errorMsg) {
					h("#itemBox").html('<div class="nodata">—— 暂无数据 ——</div>');
					app.toast("数据获取失败，请检查网络连接");
				});
			}
		</script>
		<!-- js代码 end -->
	</body>
</html>
